#include "main/utils.h"
using namespace std;

int findMaxSum(vector<int> vec) {
  int max_sum = INT_MIN;
  int sum = 0;
  for (int i = 0; i < vec.size(); ++i) {
    if (sum < 0) {
      sum = vec[i];
    } else {
      sum += vec[i];
    }
    if (sum > max_sum) {
      max_sum = sum;
    }
  }
  return max_sum;
}

int main() {
  vector<int> vec = {1, -2, 3, 10, -4, 7, 2, -5};
  int sum = findMaxSum(vec);
  cout << "The maximum sum in sub vector is: " << sum << endl;

  return 0;
}
